class @MessagesView extends ScrollPagingView

    initialize:->
        super
        @setElement("#main")
        @model.bind("change",@render)
        @model.fetch()

    render:->
        @GetTemplate(SiteMap.Messages.UserListingEmptyTemplate,(template)=>
            $(@el).html(template(@model.toJSON()))
            @startLoading()
            @renewScrolling()
            return
        )

    events:
        "click ul li":"show"
        "click button.buttons":"back"
        "click .sorting a" :"sort"

    show:(event)->
        event.preventDefault()
        @Navigate(SiteMap.Messages.MessageListing+"?senderId="+$(event.currentTarget).data("sender-id"),true)
        return

    back:(event)->
        event.preventDefault()
        @Navigate(SiteMap.Home.Index, true)

    afterLoad: (data) =>
        @GetTemplate(SiteMap.Messages.UserListingTemplate, (compiledTemplate) =>
            $(@el).find("ul.user-listing").append(compiledTemplate(data))
        )
    sort:(event)->
        event.preventDefault()
        element = $(event.currentTarget)
        @model.set("Column",element.data("sort-option"), {silent: true})
        @model.set("Direction",element.data("sort-direction"), {silent: true})
        @model.set("Page",1, {silent: true})
        @model.fetch()
